package com.xl.bigdata.es;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * @program: IAEngine
 * @description:
 * @author: XL.Gao
 * @create: 2021-08-21 14:11
 **/
public class ESRestHighLevelClient {

    private static RestHighLevelClient client = null;

    public static synchronized RestHighLevelClient getEsClient() {
        if (client == null) {
            client = new RestHighLevelClient(RestClient.builder(
                    new HttpHost("10.155.20.101", 9200, "http")
            ));
        }

//        System.out.println(client.indices().);

        return client;
    }

    public static void main(String[] args) {
        getEsClient();
    }
}
